//
//  TTCommondDataModel.m
//  TaoTuo
//
//  Created by admin on 2019/8/26.
//  Copyright © 2019 admin. All rights reserved.
//

#import "TTCommondDataModel.h"
#import "TTShopCartSubDetailModel.h"
#import "TTDiamondModel.h"
#import "TTDetailStockListModel.h"

@implementation TTCommondDataModel

+ (NSDictionary *)getClarityCharacteristics
{
    return @{
             @"Bruise" : @"淤痕",
             @"Cloud" : @"云雾",
             @"Crystal" : @"晶状体",
             @"Chip" : @"缺口",
             @"Cavity" : @"洞穴",
             @"Knot" : @"晶结",
             @"Indented Natural" : @"内凹天然晶面",
             @"Natural" : @"原始晶面",
             @"Feather" : @"羽裂纹",
             @"Needle" : @"针状物",
             @"Laser Drill Hole" : @"激光洞",
             @"Reflecting Surface Graining" : @"反射外部结晶纹",
             @"Internal Graining" : @"内部结晶纹",
             @"Surface Graining" : @"外部结晶纹",
             @"Manufacturing Remnant" : @"生产残留物",
             @"Minor Details of Polish" : @"细微抛光痕",
             @"Pinpoint" : @"针点",
             @"Twinning Wisp" : @"孪晶纹",
             @"Extra Facet" : @"额外刻面",
             @"Etch Channel" : @"凹蚀管"
             };
}

// 到达深圳的时间
+ (NSDictionary *)toShenZhenTime
{
    return @{
             @"美国" : @"约14天到深圳",
             @"比利时" : @"约10天到深圳",
             @"以色列" : @"约10天到深圳",
             @"迪拜" : @"约10天到深圳",
             @"香港" : @"约5天到深圳",
             @"印度" : @"约7天到深圳",
             @"上海" : @"约3天到深圳",
             @"孟买" : @"约7天到深圳",
             @"深圳" : @"深圳",
             };
}


// 形状图片
+ (NSDictionary *)findShapeImageName
{
    return @{
             @"圆形" : @"Detail_1",
             @"梨形" : @"Detail_6",
             @"心形" : @"Detail_8",
             @"垫形" : @"Detail_4",
             @"祖母绿" : @"Detail_3",
             @"三角形" : @"Detail_10",
             @"椭圆形" : @"Detail_5",
             @"公主方" : @"Detail_2",
             @"雷蒂恩" : @"Detail_9",
             @"马眼" : @"Detail_7",
             @"阿斯切" : @"Detail_11",
             @"其他" : @"Detail_12",
             @"CUT (RSC)" : @"Detail_12"
             };
}

+ (TTShopCartSubDetailModel *)diamondModelToShopCartSubDetailModelWithModel:(TTDiamondModel *)model
{
    NSString *title = [NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@ %@ %@", model.Shape, model.DiaSize, model.Color, model.Clarity, model.Cut, model.Sym, model.Polish, model.Flour];
    NSString *certUrlStr = model.Certificate;
    NSString *price = model.Price;
    TTShopCartSubDetailModel *detailModel = [[TTShopCartSubDetailModel alloc] init];
    detailModel.GoodsTitle = title;
    NSString *str = [NSString stringWithFormat:@"%@ %@ %@", model.Milky, model.Browness, model.EyeClean];
    detailModel.GoodsDescribe = @[str];
    detailModel.GoodsPrice = price;
    detailModel.CertPic = certUrlStr;
    detailModel.Cert = model.Cert;
    detailModel.DiaSize = model.DiaSize;
    detailModel.GoodsType = 1;
    detailModel.GoodsBarCode = [NSString stringWithFormat:@"%@_%@", model.CertNo, model.SupplierNo];
    NSString *goodsImage = [NSString stringWithFormat:@"http://taotuo.oss-cn-hangzhou.aliyuncs.com/TaoTuoApp/Diamonds/icon/%@.png", model.Shape];
    detailModel.GoodsImage = goodsImage;
    detailModel.CertPic = model.Certificate;
    detailModel.Cert = model.Cert;
    detailModel.CertNo = model.CertNo;
    detailModel.Number = 1;
    detailModel.Status = @"1";
    detailModel.SouthAfrica = model.SouthAfrica;
    detailModel.LocationName = model.Location;
    detailModel.CategoryName = @"裸石";
    detailModel.ProductText = model.DiaSource;
    detailModel.ClarityCharacteristics = model.ClarityCharacteristics;
    detailModel.InsertSize = [NSString stringWithFormat:@"%d", [TTLoginSingle findDiamondSizeWithSize:model.DiaSize.floatValue * 100]];
    NSString *timeStr = [TTCommondDataModel toShenZhenTime][model.Location];
    if (timeStr.length == 0) {
        timeStr = @"0";
    }
    NSString *regexStr = @"\\d";
    NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:regexStr options:NSRegularExpressionCaseInsensitive error:nil];
    NSArray *array = [regular matchesInString:timeStr options:NSMatchingReportCompletion range:NSMakeRange(0, timeStr.length)];
    NSTextCheckingResult *result = array.firstObject;
    NSString *days = [timeStr substringWithRange:result.range];
    detailModel.MadeCircle = days;
    detailModel.h = 65 * kScale + 40;
    
    return detailModel;
}




// 店铺中 转化成提交订单所需要的model
+ (TTShopCartSubDetailModel *)orderShopModelToShopCartSubDetailModel:(TTOrderShopModel *)orderShopModel
{
    TTShopCartSubDetailModel *dm = [[TTShopCartSubDetailModel alloc] init];
    dm.Id = orderShopModel.Id;
    dm.GoodsBarCode = orderShopModel.GoodsBarCode;
    dm.GoodsType = orderShopModel.GoodsType;
    dm.GoodsTitle = orderShopModel.GoodsTitle;
    dm.GoodsImage = orderShopModel.GoodsImage;
    dm.GoodsDescribe = [orderShopModel.GoodsDescribeTaotuo componentsSeparatedByString:@","];
    dm.GoodsPrice = orderShopModel.GoodsPrice;
    dm.Cert = orderShopModel.GoodsCertType;
    dm.CertType = orderShopModel.GoodsCertType;
    dm.CertNo = orderShopModel.GoodsCertNo;
    dm.CertPic = orderShopModel.GoodsCertPic;
    dm.FinishedProduct = orderShopModel.IsFinishedProduct;
    dm.CategoryName = orderShopModel.CategoryName;
    dm.Number = 1;
    dm.StyleLibraryId = orderShopModel.StyleLibraryId;
    dm.InsertSize = orderShopModel.InsertSize;
    dm.GoodsValuationPriceTypeText = orderShopModel.GoodsValuationPriceTypeText;
    dm.FinishedProduct = orderShopModel.FinishedProduct;
    dm.LocationName = orderShopModel.GoodsLocation;
    dm.Status = orderShopModel.SysStatus;
    dm.SouthAfrica = orderShopModel.SouthAfrica;
    dm.FactoryLabel = orderShopModel.FactoryLabel;
    dm.h = orderShopModel.h;
    return dm;
}

@end
